package iwhr.nsbd.util;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.time.LocalDateTime;

public class TimeRange {
        private LocalDateTime startDateTime;
        private LocalDateTime endDateTime;

        public TimeRange(LocalDateTime startDateTime, LocalDateTime endDateTime) {
            this.startDateTime = startDateTime;
            this.endDateTime = endDateTime;
        }

        public LocalDateTime getStartDateTime() {

            return startDateTime;
        }

        public void setStartDateTime(LocalDateTime startDateTime) {
            this.startDateTime = startDateTime;
        }

        public LocalDateTime getEndDateTime() {
            return endDateTime;
        }

        public void setEndDateTime(LocalDateTime endDateTime) {
            this.endDateTime = endDateTime;
        }

        public static TimeRange getRangeAtIndex(List<TimeRange> timeRanges, int index) {
            if (timeRanges != null && index >= 0 && index < timeRanges.size()) {
                return timeRanges.get(index);
            }
            return null;
        }

    @Override
    public String toString() {
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
        return "开始时间：" + startDateTime.format(formatter) +
                ",结束时间：" + endDateTime.format(formatter) +"\n";
    }
    }
